<?php
defined('IN_IA') or exit('Access Denied');
global $_W, $_GPC;
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ('delall_caiji' == $op) {
	$list = pdo_fetch("SELECT * FROM " . tablename($this->tablecaijiall) . " WHERE uniacid = '{$_W['uniacid']}'");
	if ($list) {
		pdo_delete($this->tablecaijiall, array('uniacid' => $_W['uniacid']));
		message('操作成功！', $this->createWebUrl('listcaijiall_hdk'), 'success');
	} else {
		message('未发现已采集商品！', $this->createWebUrl('listcaijiall_hdk'), 'error');
	}
}
if ('show_none' == $op) {
	$list = pdo_fetch("SELECT * FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}' AND status=0");
	if ($list) {
		pdo_delete($this->tableitemall, array('uniacid' => $_W['uniacid'], 'status' => 0));
		message('操作成功！', $this->createWebUrl('listitemall', array('op' => 'display')), 'success');
	} else {
		message('未发现已下架商品！', $this->createWebUrl('listitemall', array('op' => 'display')), 'error');
	}
}
if ('xiajia_daoqi' == $op) {
	$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}'");
	foreach ($list as $key => $value) {
		if (time() - strtotime($list[$key]['itemyhj_etime']) >= 86400 && !empty($list[$key]['itemyhj_url'])) {
			$data = array('status' => 0,);
			pdo_update($this->tableitemall, $data, array('id' => $list[$key]['id']));
		}
	}
	message('操作成功！', $this->createWebUrl('listitemall', array('op' => 'display')), 'success');
}
if ('del_daoqi' == $op) {
	$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}'");
	foreach ($list as $key => $value) {
		if (time() - strtotime($list[$key]['itemyhj_etime']) >= 86400 && !empty($list[$key]['itemyhj_url'])) {
			pdo_delete($this->tableitemall, array('uniacid' => $_W['uniacid'], 'id' => $list[$key]['id']));
			pdo_delete($this->tablefav, array('uniacid' => $_W['uniacid'], 'itemid' => $list[$key]['id']));
		}
	}
	message('操作成功！', $this->createWebUrl('listitemall', array('op' => 'display')), 'success');
}
if ('xiajia_none' == $op) {
	$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}'");
	foreach ($list as $key => $value) {
		if (empty($list[$key]['itemyhj_url'])) {
			$data = array('status' => 0,);
			pdo_update($this->tableitemall, $data, array('id' => $list[$key]['id']));
		}
	}
	message('操作成功！', $this->createWebUrl('listitemall', array('op' => 'display')), 'success');
}
if ('del_none' == $op) {
	$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableitemall) . " WHERE uniacid = '{$_W['uniacid']}'");
	foreach ($list as $key => $value) {
		if (empty($list[$key]['itemyhj_url'])) {
			pdo_delete($this->tableitemall, array('uniacid' => $_W['uniacid'], 'id' => $list[$key]['id']));
			pdo_delete($this->tablefav, array('uniacid' => $_W['uniacid'], 'itemid' => $list[$key]['id']));
		}
	}
	message('操作成功！', $this->createWebUrl('listitemall', array('op' => 'display')), 'success');
}